package com.macro.mall.demo2.service.impl;

import com.macro.mall.demo2.dao.PmsProtalProductDetailMapper;
import com.macro.mall.demo2.dto.PmsPortalProductDetail;
import com.macro.mall.demo2.service.PmsProtalProductDetailService;
import com.macro.mall.mapper.PmsBrandMapper;
import com.macro.mall.mapper.PmsProductMapper;
import com.macro.mall.model.PmsBrand;
import com.macro.mall.model.PmsProduct;
import com.macro.mall.model.PmsProductAttribute;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author：贾维斯
 * @Description: 描述
 * @name：PmsProtalProductDetailServiceImpl
 * @Date：2024/10/20 19:04
 */
@Service
public class PmsProtalProductDetailServiceImpl4 implements PmsProtalProductDetailService {
    @Autowired
    private PmsProtalProductDetailMapper pmsProtalProductDetailMapper;

    @Autowired
    private PmsProductMapper pmsProductMapper;

    @Autowired
    private PmsBrandMapper pmsBrandMapper;


    @Override
    public PmsPortalProductDetail  selectById(Long id) {
        //获取商品信息
        PmsProduct pmsProduct = pmsProductMapper.selectByPrimaryKey(id);
        //获取品牌信息
        PmsBrand pmsBrand = pmsBrandMapper.selectByPrimaryKey(pmsProduct.getBrandId());
        //获取商品属性信息
        List<PmsProductAttribute> pmsPortalProductDetail = pmsProtalProductDetailMapper.selectById(pmsProduct.getProductAttributeCategoryId());

        PmsPortalProductDetail pmsPortalProductDetail1 = new PmsPortalProductDetail();
        pmsPortalProductDetail1.setProduct(pmsProduct);
        pmsPortalProductDetail1.setBrand(pmsBrand);
        pmsPortalProductDetail1.setProductAttributeList(pmsPortalProductDetail);
        return pmsPortalProductDetail1;
    }
}
